#!/usr/bin/perl

package Foo;
use base 'Class::C3::Componentised';
sub component_base_class { "Foo" }

sub new {
    my $class = shift;
    bless{n=>undef},$class;
}

sub call{
    my $self = shift;
    return;
}

package Foo::Buzz;
use base qw/ Foo /;

sub call{
    my $self = shift;
    my $n = [];
    for my $i (@{$self->{n}}){
       $i = 'Buzz' unless( $i =~ /(Fizz|Buzz)/ || $i%5 ); 
       push @{$n},$i;
    }
    $self->{n} = $n;
    $self->next::method();
    return;
}

package Foo::Fizz;
use base qw/ Foo /;

sub call{
    my $self = shift;
    my $n = [];
    for my $i (@{$self->{n}}){
       $i = 'Fizz' unless( $i =~ /FizzBuzz/ || $i%3 ); 
       push @{$n},$i;
    }
    $self->{n} = $n;
    $self->next::method();
    return;
}

package Foo::FizzBuzz;
use base qw/ Foo /;

sub call{
    my $self = shift;
    my $n = [];
    for my $i (@{$self->{n}}){
       $i = 'FizzBuzz' unless( $i%15 ); 
       push @{$n},$i;
    }
    $self->{n} = $n;
    $self->next::method();
    return;
}

package Foo::Hoge;
use base qw/ Foo /;

sub call{
    my $self = shift;
    $self->{n} = shift;
    $self->next::method();
    return $self->{n};
}


Foo::Hoge->load_components('FizzBuzz','Fizz','Buzz');
my $foo = new Foo::Hoge();

map{print "$_\n";} @{$foo->call([1..100])};


